import { Schema, ArraySchema,MapSchema,type } from "@colyseus/schema";
import _ from 'lodash'

export class Card extends Schema{
    @type('number') val
    @type('number') color //0为白 1为黑
    @type('boolean') isExpose = false 

    constructor(val:number,color:number){
        super()
        this.val = val
        this.color = color
    }
}

export class Player extends Schema{
    @type("string") name
    @type("boolean") connected = true
    @type("boolean") isOut = false
    @type([Card]) cardsOfPlayer = new ArraySchema<Card> ()
    @type('string') curCard = ''
    
    constructor(name:string){
        super()
        this.name = name
    }
}



export class GameState extends Schema{
    @type({map:Player}) players = new MapSchema<Player>()
    @type("boolean") isGaming = false
    @type("string") host = ''
    @type('number') cur = 0
    
    cards = _.range(24)
}